﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace Mall.Order
{
    public partial class Order_Address : System.Web.UI.Page
    {
        public MODEL.MOrder model_order = new MODEL.MOrder();
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断是否登陆
            BLL.Models.MemberModels models_member = new BLL.Models.MemberModels();

            string username = models_member.CheckUserIdOrder();// CheckUserIdOrder();
            DataTable dt = new DataTable();
            dt = models_member.GetuserInfoByFiter(" username='" + username + "'");
            DataRow dr = dt.Rows[0];
            model_order.RecAddress = dr["address"].ToString();
            model_order.RecMobile = dr["mobile"].ToString();
            model_order.RecName = dr["name"].ToString();
            model_order.RecZip = dr["zipcode"].ToString();
            //TempData["model_order"] = model_order;
            //取得用户信息
            if (Request["ctl00_MainPlace_txtCellphone1"] != null)
            {

                BLL.Models.MOrderModels models = new BLL.Models.MOrderModels();
                model_order.OrderNum = models.GetOrderNumbernew();


                model_order.Userid = Convert.ToInt32(models_member.GetUserIdByName(username));
                model_order.RecMobile = Request["ctl00_MainPlace_txtCellphone1"];
                model_order.RecZip = Request["ctl00_MainPlace_txtPostCode1"];
                model_order.RecAddress = Request["ctl00_MainPlace_cmbProvince"] + Request["ctl00_MainPlace_cmbCity"] + Request["ctl00_MainPlace_txtAddress"];
                model_order.RecName = Request["ctl00_MainPlace_txtCustomerName"];
                //TempData["model_order"] = model_order;
                MODEL.MMember model_menber = new MODEL.MMember();
                model_menber.UserName = username;
                model_menber.Mobile = model_order.RecMobile;
                model_menber.ZipCode = model_order.RecZip;
                model_menber.Address = model_order.RecAddress;
                model_menber.Name = model_order.RecName;
                models_member.UpdateSimgUser(model_menber);
               // return RedirectToAction("order_ship", "order");
            }
        }
    }
}